﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LizzabethBrownRealEstate.Models;

namespace LizzabethBrownRealEstate.Controllers
{
    public class HomeController : Controller
    {
        private LBRDataContext dc = new LBRDataContext();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Error()
        {
            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult Search()
        {
            return View();
        }

        public ActionResult Extras()
        {
            return View(); 
        }

        public IEnumerable<RealEstateProperty> GetFeaturedProperties()
        {
           

            var props = dc.RealEstateProperties.Where<RealEstateProperty>(p => p.Feature == true && p.Deleted==false);
            //if (props == null) props = new List<RealEstateProperty>();
            IEnumerable<RealEstateProperty> l = props.AsEnumerable<RealEstateProperty>();
            return l;
        }

        public IEnumerable<Event> GetEvents()
        {
            IEnumerable<Event> eventList = dc.Events.AsEnumerable<Event>().Where<Event>(e => e.Deleted = false);
            return eventList;
        }

        public ActionResult ViewEvent(int eventId)
        {
            ViewData.Add("EventId", eventId);
            return View();
        }

        public ActionResult ViewProperty(int propertyId)
        {
            ViewData.Add("PropertyId", propertyId);
            return View();
        }
    }
}
